home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 02 / borland / min.c next >
C/C++ Source or Header  |  1990-11-20  |  3KB  |  80 lines

  1. /*-------------------------------------------------------------*\
  2.  |   MIN.C   A Minimum Windows Program that displays a window. |
  3.  |           The window can be moved, sized, minimized and     |
  4.  |           maximized.  The WM_QUIT message is correctly      |
  5.  |           handled so that the program terminates properly.  |
  6. \*-------------------------------------------------------------*/
  7. #include <Windows.H>
  8.  
  9. /*-------------------------------------------------------------*\
  10.  |                    Function Prototypes.                     |
  11. \*-------------------------------------------------------------*/
  12. long FAR  PASCAL MinWndProc (HWND, WORD, WORD, LONG);
  13.  
  14. /*-------------------------------------------------------------*\
  15.  |                 Main Function:  WinMain.                    |
  16. \*-------------------------------------------------------------*/
  17. int PASCAL WinMain (HANDLE hInstance,   HANDLE hPrevInstance,
  18.                     LPSTR  lpszCmdLine, int    cmdShow)
  19.     {
  20.     HWND     hwnd;
  21.     MSG      msg;
  22.     WNDCLASS wndclass;
  23.  
  24.     if (!hPrevInstance)
  25.         {
  26.         wndclass.lpszClassName = "MIN:MAIN";
  27.         wndclass.hInstance     = hInstance;
  28.         wndclass.lpfnWndProc   = MinWndProc;
  29.         wndclass.hCursor       = LoadCursor (hInstance, "hand");
  30.         wndclass.hIcon         = LoadIcon (hInstance,"snapshot");
  31.         wndclass.lpszMenuName  = NULL;
  32.         wndclass.hbrBackground = COLOR_WINDOW+1;
  33.         wndclass.style         = NULL;
  34.         wndclass.cbClsExtra    = 0;
  35.         wndclass.cbWndExtra    = 0;
  36.  
  37.         RegisterClass( &wndclass);
  38.         }
  39.  
  40.     hwnd = CreateWindow("MIN:MAIN",           /* Class name.   */
  41.                         "Minimum",            /* Title.        */
  42.                         WS_OVERLAPPEDWINDOW,  /* Style bits.   */
  43.                         CW_USEDEFAULT,        /* x - default.  */
  44.                         0,                    /* y - default.  */
  45.                         CW_USEDEFAULT,        /* cx - default. */
  46.                         0,                    /* cy - default. */
  47.                         NULL,                 /* No parent.    */
  48.                         NULL,                 /* Class menu.   */
  49.                         hInstance,            /* Creator.      */
  50.                         NULL);                /* Params.       */
  51.  
  52.     ShowWindow (hwnd, cmdShow);
  53.  
  54.     while (GetMessage(&msg, 0, 0, 0))
  55.         {
  56.         TranslateMessage(&msg);       /*  Keyboard input.      */
  57.         DispatchMessage(&msg);
  58.         }
  59.     return 0;
  60.     }
  61.  
  62. /*-------------------------------------------------------------*\
  63.  |              Window Procedure:  MinWndProc.                 |
  64. \*-------------------------------------------------------------*/
  65. long FAR PASCAL MinWndProc (HWND hwnd,   WORD wMsg,
  66.                             WORD wParam, LONG lParam)
  67.     {
  68.     switch (wMsg)
  69.         {
  70.         case WM_DESTROY:
  71.             PostQuitMessage(0);
  72.             break;
  73.  
  74.         default:
  75.             return(DefWindowProc(hwnd,wMsg,wParam,lParam));
  76.             break;
  77.         }
  78.     return 0L;
  79.     }
  80.